package com.jason.concurrent.list;


import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

public class ThreadDemo1 {
    public static void main(String[] args) {

//        Vector<String> strings = new Vector<>();
        List<String> strings = new CopyOnWriteArrayList<>();
        strings.add("ss");
        List<String> integers = Collections.synchronizedList(new ArrayList<>());
        for (int i = 0; i < 20; i++) {
            new Thread(()->{
                integers.add(UUID.randomUUID().toString().substring(0,8));
                System.out.println(integers);
            },String.valueOf(i)).start();


        }

        Set<String>set = new HashSet<>();
        //线程不安全的

        Set<String>set1 = new CopyOnWriteArraySet<>();
        Map<String,String>hashMap = new ConcurrentHashMap<>();
    }
}
